<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>rapidjson: rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt; Class Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">rapidjson
   </div>
   <div id="projectbrief">A fast JSON parser/generator for C++ with both SAX/DOM style API</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="hierarchy.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>rapidjson</b></li><li class="navelem"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">MemoryPoolAllocator</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-static-methods">Static Public Member Functions</a> &#124;
<a href="#pub-static-attribs">Static Public Attributes</a> &#124;
<a href="classrapidjson_1_1_memory_pool_allocator-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt; Class Template Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Default memory allocator used by the parser and DOM.  
 <a href="classrapidjson_1_1_memory_pool_allocator.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="rapidjson_8h_source.html">rapidjson.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt;:</div>
<div class="dyncontent">
 <div class="center">
  <img src="classrapidjson_1_1_memory_pool_allocator.png" usemap="#rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt;_map" alt=""/>
  <map id="rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt;_map" name="rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt;_map">
<area href="classrapidjson_1_1_allocator.html" title="Concept for allocating, resizing and freeing memory block." alt="rapidjson::Allocator" shape="rect" coords="0,0,295,24"/>
</map>
 </div></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="nested-classes"></a>
Classes</h2></td></tr>
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top">struct &#160;</td><td class="memItemRight" valign="bottom"><b>ChunkHeader</b></td></tr>
<tr class="memdesc:"><td class="mdescLeft">&#160;</td><td class="mdescRight">Chunk header for perpending to each chunk. <br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a59d783f4feba17dcd35d9f25fcbc09f4"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a59d783f4feba17dcd35d9f25fcbc09f4">MemoryPoolAllocator</a> (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)</td></tr>
<tr class="memdesc:a59d783f4feba17dcd35d9f25fcbc09f4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor with chunkSize.  <a href="#a59d783f4feba17dcd35d9f25fcbc09f4"></a><br/></td></tr>
<tr class="memitem:a60f938294865887ce0c52351dd786ba2"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a60f938294865887ce0c52351dd786ba2">MemoryPoolAllocator</a> (char *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)</td></tr>
<tr class="memdesc:a60f938294865887ce0c52351dd786ba2"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor with user-supplied buffer.  <a href="#a60f938294865887ce0c52351dd786ba2"></a><br/></td></tr>
<tr class="memitem:aa1d5b36c67611937e8ad6b2be53a483e"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#aa1d5b36c67611937e8ad6b2be53a483e">~MemoryPoolAllocator</a> ()</td></tr>
<tr class="memdesc:aa1d5b36c67611937e8ad6b2be53a483e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor.  <a href="#aa1d5b36c67611937e8ad6b2be53a483e"></a><br/></td></tr>
<tr class="memitem:aa050d52c62503ca6d6f66289ce83a18e"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="aa050d52c62503ca6d6f66289ce83a18e"></a>
void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#aa050d52c62503ca6d6f66289ce83a18e">Clear</a> ()</td></tr>
<tr class="memdesc:aa050d52c62503ca6d6f66289ce83a18e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Deallocates all memory chunks, excluding the user-supplied buffer. <br/></td></tr>
<tr class="memitem:a83cb7583387121061ccf8efe47af3f0e"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a83cb7583387121061ccf8efe47af3f0e">Capacity</a> ()</td></tr>
<tr class="memdesc:a83cb7583387121061ccf8efe47af3f0e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the total capacity of allocated memory chunks.  <a href="#a83cb7583387121061ccf8efe47af3f0e"></a><br/></td></tr>
<tr class="memitem:a84bc10e2c40adb258b4759617f4fdf58"><td class="memItemLeft" align="right" valign="top">size_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a84bc10e2c40adb258b4759617f4fdf58">Size</a> ()</td></tr>
<tr class="memdesc:a84bc10e2c40adb258b4759617f4fdf58"><td class="mdescLeft">&#160;</td><td class="mdescRight">Computes the memory blocks allocated.  <a href="#a84bc10e2c40adb258b4759617f4fdf58"></a><br/></td></tr>
<tr class="memitem:a208c29e04b1d748bfe068444b7044344"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a208c29e04b1d748bfe068444b7044344"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a208c29e04b1d748bfe068444b7044344">Malloc</a> (size_t size)</td></tr>
<tr class="memdesc:a208c29e04b1d748bfe068444b7044344"><td class="mdescLeft">&#160;</td><td class="mdescRight">Allocates a memory block. (concept <a class="el" href="classrapidjson_1_1_allocator.html" title="Concept for allocating, resizing and freeing memory block.">Allocator</a>) <br/></td></tr>
<tr class="memitem:a880524b17bbecb5d2691b8075050d55d"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a880524b17bbecb5d2691b8075050d55d"></a>
void *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a880524b17bbecb5d2691b8075050d55d">Realloc</a> (void *originalPtr, size_t originalSize, size_t newSize)</td></tr>
<tr class="memdesc:a880524b17bbecb5d2691b8075050d55d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Resizes a memory block (concept <a class="el" href="classrapidjson_1_1_allocator.html" title="Concept for allocating, resizing and freeing memory block.">Allocator</a>) <br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr class="memitem:adf56bd613959a956b5bc57debd0a6aa9"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adf56bd613959a956b5bc57debd0a6aa9"></a>
static void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#adf56bd613959a956b5bc57debd0a6aa9">Free</a> (void *)</td></tr>
<tr class="memdesc:adf56bd613959a956b5bc57debd0a6aa9"><td class="mdescLeft">&#160;</td><td class="mdescRight">Frees a memory block (concept <a class="el" href="classrapidjson_1_1_allocator.html" title="Concept for allocating, resizing and freeing memory block.">Allocator</a>) <br/></td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="pub-static-attribs"></a>
Static Public Attributes</h2></td></tr>
<tr class="memitem:a2606d96e19bcfc9d4bf58aefe55c1b29"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2606d96e19bcfc9d4bf58aefe55c1b29"></a>
static const bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a2606d96e19bcfc9d4bf58aefe55c1b29">kNeedFree</a> = false</td></tr>
<tr class="memdesc:a2606d96e19bcfc9d4bf58aefe55c1b29"><td class="mdescLeft">&#160;</td><td class="mdescRight">Tell users that no need to call <a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#adf56bd613959a956b5bc57debd0a6aa9" title="Frees a memory block (concept Allocator)">Free()</a> with this allocator. (concept <a class="el" href="classrapidjson_1_1_allocator.html" title="Concept for allocating, resizing and freeing memory block.">Allocator</a>) <br/></td></tr>
</table>
<a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename BaseAllocator = CrtAllocator&gt;<br/>
class rapidjson::MemoryPoolAllocator&lt; BaseAllocator &gt;</h3>

<p>Default memory allocator used by the parser and DOM. </p>
<p>This allocator allocate memory blocks from pre-allocated memory chunks.</p>
<p>It does not free memory blocks. And <a class="el" href="classrapidjson_1_1_memory_pool_allocator.html#a880524b17bbecb5d2691b8075050d55d" title="Resizes a memory block (concept Allocator)">Realloc()</a> only allocate new memory.</p>
<p>The memory chunks are allocated by BaseAllocator, which is <a class="el" href="classrapidjson_1_1_crt_allocator.html" title="C-runtime library allocator.">CrtAllocator</a> by default.</p>
<p>User may also supply a buffer as the first chunk.</p>
<p>If the user-buffer is full then additional chunks are allocated by BaseAllocator.</p>
<p>The user-buffer is not deallocated by this allocator.</p>
<dl class="tparams"><dt>Template Parameters</dt><dd>
  <table class="tparams">
    <tr><td class="paramname">BaseAllocator</td><td>the allocator type for allocating memory chunks. Default is <a class="el" href="classrapidjson_1_1_crt_allocator.html" title="C-runtime library allocator.">CrtAllocator</a>. </td></tr>
  </table>
  </dd>
</dl>
</div><h2>Constructor &amp; Destructor Documentation</h2>
<a class="anchor" id="a59d783f4feba17dcd35d9f25fcbc09f4"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename BaseAllocator  = CrtAllocator&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">rapidjson::MemoryPoolAllocator</a>&lt; BaseAllocator &gt;::<a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">MemoryPoolAllocator</a> </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>chunkSize</em> = <code>kDefaultChunkCapacity</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">BaseAllocator *&#160;</td>
          <td class="paramname"><em>baseAllocator</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructor with chunkSize. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">chunkSize</td><td>The size of memory chunk. The default is kDefaultChunkSize. </td></tr>
    <tr><td class="paramname">baseAllocator</td><td>The allocator for allocating memory chunks. </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a60f938294865887ce0c52351dd786ba2"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename BaseAllocator  = CrtAllocator&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">rapidjson::MemoryPoolAllocator</a>&lt; BaseAllocator &gt;::<a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">MemoryPoolAllocator</a> </td>
          <td>(</td>
          <td class="paramtype">char *&#160;</td>
          <td class="paramname"><em>buffer</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>size</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>chunkSize</em> = <code>kDefaultChunkCapacity</code>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">BaseAllocator *&#160;</td>
          <td class="paramname"><em>baseAllocator</em> = <code>0</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Constructor with user-supplied buffer. </p>
<p>The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size. </p>
<pre class="fragment">    The user buffer will not be deallocated when this allocator is destructed.

    \param buffer User supplied buffer.
    \param size Size of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
    \param chunkSize The size of memory chunk. The default is kDefaultChunkSize.
    \param baseAllocator The allocator for allocating memory chunks.</pre> 
</div>
</div>
<a class="anchor" id="aa1d5b36c67611937e8ad6b2be53a483e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename BaseAllocator  = CrtAllocator&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">rapidjson::MemoryPoolAllocator</a>&lt; BaseAllocator &gt;::~<a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">MemoryPoolAllocator</a> </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Destructor. </p>
<p>This deallocates all memory chunks, excluding the user-supplied buffer. </p>

</div>
</div>
<h2>Member Function Documentation</h2>
<a class="anchor" id="a83cb7583387121061ccf8efe47af3f0e"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename BaseAllocator  = CrtAllocator&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">size_t <a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">rapidjson::MemoryPoolAllocator</a>&lt; BaseAllocator &gt;::Capacity </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Computes the total capacity of allocated memory chunks. </p>
<dl class="section return"><dt>Returns</dt><dd>total capacity in bytes. </dd></dl>

</div>
</div>
<a class="anchor" id="a84bc10e2c40adb258b4759617f4fdf58"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename BaseAllocator  = CrtAllocator&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">size_t <a class="el" href="classrapidjson_1_1_memory_pool_allocator.html">rapidjson::MemoryPoolAllocator</a>&lt; BaseAllocator &gt;::Size </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Computes the memory blocks allocated. </p>
<dl class="section return"><dt>Returns</dt><dd>total used bytes. </dd></dl>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/rapidjson_version0.1x/include/rapidjson/<a class="el" href="rapidjson_8h_source.html">rapidjson.h</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Nov 16 2012 21:08:20 for rapidjson by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.1.2
</small></address>
</body>
</html>
